ga.core.algorithm.util
Class ClusterUtil

java.lang.Object
  extended by ga.core.algorithm.util.ClusterUtil

public final class ClusterUtil
extends java.lang.Object

Utility class for handling clusters.

Since:
11.08.2012
Author:
Stephan Dreyer

Constructor Summary
private ClusterUtil()
          Instantiation is not allowed.
 
Method Summary
static
<T extends IClusterableIndividual<T>>
void
assignFitness(java.util.List<org.apache.commons.math.stat.clustering.Cluster<T>> clusters, T ind)
          Assigns the fitness depending on the type of individual.
static
<T extends IClusterableIndividual<T>,I extends IIntervalFitness>
void
assignIntervalFitness(org.apache.commons.math.stat.clustering.Cluster<T> cluster, I ind)
          Assigns an interval fitness if the individual is an instance of IIntervalFitness.
static
<T extends IClusterableIndividual<T>,I extends IFitness>
void
assignNumericFitness(org.apache.commons.math.stat.clustering.Cluster<T> cluster, I ind)
          Assigns the fitness of one individual to all individuals of the cluster.
static
<T extends IClusterableIndividual<T>>
T
calculateCentroid(java.util.Collection<T> c)
          Calculates the centroid of the collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterUtil

private ClusterUtil()
Instantiation is not allowed.

Since:
11.08.2012
Method Detail

calculateCentroid

public static <T extends IClusterableIndividual<T>> T calculateCentroid(java.util.Collection<T> c)
Calculates the centroid of the collection. This is the individual of the collection, that has the lowest distance to all other individuals.

Type Parameters:
T - The generic type of the individuals.
Parameters:
c - Collection of individuals.
Returns:
The centroid individual.
Since:
11.08.2012

assignFitness

public static <T extends IClusterableIndividual<T>> void assignFitness(java.util.List<org.apache.commons.math.stat.clustering.Cluster<T>> clusters,
                                                                       T ind)
Assigns the fitness depending on the type of individual.

Type Parameters:
T - The generic type of the individuals.
Parameters:
clusters - The list of all clusters.
ind - The individual that already has fitness assigned.
Since:
11.08.2012
See Also:
assignNumericFitness(Cluster, IFitness), assignIntervalFitness(Cluster, IIntervalFitness)

assignIntervalFitness

public static <T extends IClusterableIndividual<T>,I extends IIntervalFitness> void assignIntervalFitness(org.apache.commons.math.stat.clustering.Cluster<T> cluster,
                                                                                                          I ind)
Assigns an interval fitness if the individual is an instance of IIntervalFitness.

Type Parameters:
T - The generic type of the individuals.
I - The generic type of the interval fitness individuals.
Parameters:
cluster - The cluster.
ind - The centroid of the cluster.
Since:
11.08.2012

assignNumericFitness

public static <T extends IClusterableIndividual<T>,I extends IFitness> void assignNumericFitness(org.apache.commons.math.stat.clustering.Cluster<T> cluster,
                                                                                                 I ind)
Assigns the fitness of one individual to all individuals of the cluster. This is the simpliest assignment method.

Type Parameters:
T - The generic type of the individuals.
I - The generic type of the interval fitness individuals.
Parameters:
cluster - The cluster.
ind - The centroid of the cluster.
Since:
11.08.2012